<template>
  <el-container class="home_container">
    <el-header>
      <div>
        <strong><em><span><a style="color: white;text-decoration: none" href="/">落迁忆の博客 后台管理系统</a></span></em></strong>
      </div>
      <a class="el-button" style="text-decoration: none" type="info" href="https://www.luoqianyi.top">退出</a>
    </el-header>
    <el-container>
        <el-aside :width="isCollapse ? '64px' : '200px'">
            <div class="toggle_button" @click="toggleCollapse"><i class="el-icon-s-operation" style="font-size: 36px"></i></div>
          <el-menu
            background-color="#333744"
            text-color="#fff"
            :router="true"
            :collapse-transition="false"
            :collapse="isCollapse"
            :unique-opened="true"
            active-text-color="#409EFF">
            <el-menu-item index="/managetag">
              <i class="el-icon-collection-tag"></i>
              <span slot="title">标签管理</span>
            </el-menu-item>
            <el-menu-item index="/managetype">
              <i class="el-icon-edit"></i>
              <span slot="title">分类管理</span>
            </el-menu-item>
            <el-submenu index="article">
                <template slot="title">
                  <i class="el-icon-document"></i>
                  <span>文章管理</span>
                </template>
                <el-menu-item index="/manageblog">
                  <i class="el-icon-menu"></i>
                  <span slot="title">博客管理</span>
                </el-menu-item>
                <el-menu-item index="/publish">
                  <i class="el-icon-menu"></i>
                  <span slot="title">发布文章</span>
                </el-menu-item>
            </el-submenu>
            <el-submenu index="message">
              <template slot="title">
                  <i class="el-icon-chat-dot-round"></i>
                  <span>信息管理</span>
                </template>
              <el-menu-item index="/managemessage">
                  <i class="el-icon-menu"></i>
                  <span slot="title">留言管理</span>
                </el-menu-item>
                <el-menu-item index="/managecomment">
                  <i class="el-icon-menu"></i>
                  <span slot="title">评论管理</span>
                </el-menu-item>
            </el-submenu>
            <el-menu-item index="/managemovie">
              <i class="el-icon-film"></i>
              <span slot="title">影单管理</span>
            </el-menu-item>
            <el-menu-item index="/managework">
              <i class="el-icon-office-building"></i>
              <span slot="title">作品管理</span>
            </el-menu-item>
            <el-menu-item index="/manageuser">
              <i class="el-icon-user"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>
            <el-submenu index="system">
              <template slot="title">
                  <i class="el-icon-setting"></i>
                  <span>系统设置</span>
              </template>
              <el-menu-item index="/manageauthor">
                <i class="el-icon-menu"></i>
                <span slot="title">About me管理</span>
              </el-menu-item>
              <el-menu-item index="/site">
                <i class="el-icon-menu"></i>
                <span slot="title">友链管理</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
          <div class="footer">
            <el-link :underline="false" href="http://localhost:8081">@2021 Designed By 落迁忆</el-link>
          </div>
        </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data () {
    return {
      isCollapse: false
    }
  },
  methods: {
    toggleCollapse () {
      this.isCollapse = !this.isCollapse
    },
    logout () {
      var token = sessionStorage.getItem('token')
      this.$axios.defaults.headers.Authorization = 'Bearer ' + token
      this.$axios.post('http://localhost:8082/api/logout').then(response => {
        if (response.data !== '注销成功') this.$message.error('退出失败')
        window.sessionStorage.clear()
        this.$message.success('成功退出!')
        this.$router.push('/login')
      })
    }
  }
}
</script>

<style lang="less" scoped>
.home_container{
  height: 100%;
}
.el-header{
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #ffffff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 20px;
    }
  }
}
.el-aside{
  background-color: #333744;
  .el-menu{
    border-right: none;
  }
}
.el-main{
  background-color: #eaedf1;
}
.toggle_button{
  background-color: #4a5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
.footer{
  text-align: center;
}
</style>
